package com.video.main_video.manager.apiConfig.collections;


import com.video.main_video.manager.handle.collections.AddVideoCollectionManager;
import com.video.main_video.manager.handle.collections.CollectionsAddManager;
import com.video.main_video.manager.handle.collections.CollectionsGetListManager;
import com.video.main_video.manager.handle.collections.DeleteCollectionManager;

import java.util.Objects;

public enum CollectionsEnumApi {

    collectionGetList(CollectionsGetListManager.class,"collectionGetList",1),
    collectionAdd(CollectionsAddManager.class,"collectionAdd",2),
    addVideoCollection(AddVideoCollectionManager.class,"addVideoCollection",3),
    deleteCollection(DeleteCollectionManager.class,"deleteCollection",4),
    ;

    Class name;

    String desc;

    Integer code;

    private CollectionsEnumApi(Class name, String desc,Integer code) {
        this.name = name;
        this.desc = desc;
        this.code=code;
    }


    // 通过code获取名称
    public static Class formName(int code) {
        for (CollectionsEnumApi c : CollectionsEnumApi.values()) {
            if (c.getCode() == code) {
                return c.name;
            }
        }
        return null;
    }

    // 通过code获取名称
    public static Class fromNameByDesc(String desc) {
        for (CollectionsEnumApi c : CollectionsEnumApi.values()) {
            if (Objects.equals(c.getDesc(), desc)) {
                return c.name;
            }
        }
        return null;
    }
    // 通过名称获取code
    public static Integer formCode(Class name) {
        for (CollectionsEnumApi c : CollectionsEnumApi.values()) {
            if (Objects.equals(c.getName(), name)) {
                return c.code;
            }
        }
        return null;
    }

    public Class getName() {
        return name;
    }

    public void setName(Class name) {
        this.name = name;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }
}
